package com.sweet.math;

import java.math.BigDecimal;

/**
 * 数字工具
 *
 * @author limi
 * @version 2018-01-24-17:38
 */
public final class MathUtil {
    private MathUtil() {
    }

    /**
     * 数字转换
     *
     * @param total
     * @return
     */
    public static long toLong(Object total) {
        long data = 0l;
        if (total instanceof BigDecimal) {
            data = ((BigDecimal) total).longValue();
        } else if (total instanceof Long) {
            data = (Long) total;
        } else if (total instanceof Integer) {
            data = (Integer) total;
        }

        return data;
    }
}
